#include "dist_calculator.h"
#include "elements.h"

#define BOOST_AUTO_TEST_MAIN
#define BOOST_TEST_DYN_LINK

#include <boost/test/auto_unit_test.hpp>
#include <boost/test/test_tools.hpp>

#include <boost/assign/std/vector.hpp>

using namespace std;
using namespace boost::assign;

BOOST_AUTO_TEST_CASE(dist2_test) {
    DistCalculator2 c2;
    for(size_t i = 0; i < SIZE_VMSK; ++i) {
        BOOST_CHECK_EQUAL(c2(i, i), 0);
    }
    BOOST_CHECK_EQUAL(c2(0, SIZE_VMSK - 1), n);
    BOOST_CHECK_EQUAL(c2(0, 1), 1);
    BOOST_CHECK_EQUAL(c2(2, 1), 2);
    BOOST_CHECK_EQUAL(c2(3, 1), 1);
}

BOOST_AUTO_TEST_CASE(dist3_test) {
    DistCalculator3 c3;
    for(size_t i = 0; i < SIZE_VMSK; ++i) {
        BOOST_CHECK_EQUAL(c3(i, i), 0);
    }
    BOOST_CHECK_EQUAL(c3(0, SIZE_VMSK - 1), n);
    BOOST_CHECK_EQUAL(c3(0, 1), 1);
    BOOST_CHECK_EQUAL(c3(2, 1), 2);
    BOOST_CHECK_EQUAL(c3(3, 1), 1);


    BOOST_CHECK_EQUAL(c3(SIZE_VMSK, 0), 4);
    BOOST_CHECK_EQUAL(c3(SIZE_VMSK + 2, 0), 5);
    BOOST_CHECK_EQUAL(c3(SIZE_VMSK + 2, 2), 4);
    BOOST_CHECK_EQUAL(c3(SIZE_VMSK + 2, 3), 1);
 
    BOOST_CHECK_EQUAL(c3(elements[10], elements[30]), 4);
}

BOOST_AUTO_TEST_CASE(bit_extractor_test) {
    BOOST_CHECK_EQUAL(bit(SIZE_VMSK, 0), 2);
    BOOST_CHECK_EQUAL(bit(SIZE_VMSK, 1), 0);
    BOOST_CHECK_EQUAL(bit(SIZE_VMSK + 2, 0), 2);
    BOOST_CHECK_EQUAL(bit(SIZE_VMSK + 2, 1), 1);
}
